<?php

declare(strict_types=1);

namespace App\Model;


/**
 * @property int $id ID
 * @property int $userid 用户ID
 * @property string $contact 联系人
 * @property string $telephone 联系电话
 * @property int $live_column_id 直播类目ID
 * @property string $live_column_name 直播类目名称
 * @property string $introduce 自我介绍
 * @property string $idcard 身份证号码
 * @property int $apply_time 申请时间
 * @property int $audit_time 审核时间
 * @property int $audit_status 审核状态 0-待审核 1-审核通过 2-审核未通过
 * @property string $audit_mark 审核备注
 * @property-read null|User $user 
 * @property-read mixed $idcard_img1 身份证正面
 * @property-read mixed $idcard_img2 身份证背面
 */
class ApplyAnchor extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'apply_anchor';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'userid', 'contact', 'telephone', 'live_column_id', 'live_column_name', 'introduce', 'idcard', 'idcard_img1', 'idcard_img2', 'apply_time', 'audit_time', 'audit_status', 'audit_mark'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'userid' => 'integer', 'live_column_id' => 'integer', 'apply_time' => 'integer', 'audit_time' => 'integer', 'audit_status' => 'integer'];

    public function user() {
        return $this->hasOne(User::class, 'id', 'userid')->select(['id', 'username', 'nickname', 'avatar', 'role_id']);
    }

    public function getIdcardImg1Attribute($value){
        return img_url($value);
    }

    public function getIdcardImg2Attribute($value){
        return img_url($value);
    }
}
